<template>
<div>
  <div class="banner">
  <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
  <van-swipe-item v-for="(item,index) in  images" :key="index">
    <img v-lazy="'http://www.xiaoshuaipeng.com:8080'+item.imgSrc" alt="" >
    </van-swipe-item>
  </van-swipe>
  <!-- 封装搜索框组件 -->
    <div class="searchBox">
      <SearchBox></SearchBox>
      <van-icon name="guide-o" />
    </div>
  </div>

<div class="box">
<van-grid  :border="false">
  <van-grid-item icon="home-o" to="/find" text="整租" />
  <van-grid-item icon="friends-o" to="/find" text="合租" />
  <van-grid-item icon="search" text="地图找房" />
  <van-grid-item icon="refund-o" text="去出租" />
</van-grid>
</div>
<div class="group">
  <div class="group-title">
    <h3>租房小组</h3>
    <span class="more">更多</span>
  </div>
  <div class="group-content">
    <div class="item" v-for="item in groupsList" :key="item.id">
      <div class="left">
        <h5>{{item.title}}</h5>
        <p>{{item.desc}}</p>
      </div>
      <div class="right">
        <img :src="'http://www.xiaoshuaipeng.com:8080'+item.imgSrc" alt="">
      </div>
    </div>
  </div>
</div>
<div class="news">
 <h3>最新咨询</h3>
 <div class="news-content" v-for="item in newsList" :key="item.id">
  <div class="news-item">
    <div class="left"><img :src="'http://124.223.73.204:8080'+item.imgSrc" alt=""></div>
    <div class="right">
      <h6>{{item.title}}</h6>
      <div class="bottom">
        <span class="left-span">{{item.from}}</span>
        <span class="right-span">{{item.date}}</span>
      </div>
    </div>
  </div>
 </div>
</div>
</div>

</template>

<script>

import { banner, groups, news } from '@/api/index'
export default {
  name: 'IndexIndex',
  data () {
    return {
      images: [],
      groupsList: [],
      newsList: []
    }
  },
  async   created () {
    const bannerRes = await banner()
    this.images = bannerRes.data.body
    const groupsRes = await groups()
    this.groupsList = groupsRes.data.body
    const newsRes = await news()
    this.newsList = newsRes.data.body
  }

}
</script>

<style lang="less" scoped>
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
    body{
    background-color: grey;
  }
     img{
    width: 100%;
    height: 100%;
   }
}
.banner{
    .my-swipe {

   .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    height: 212px;
    text-align: center;
  }

}
 .searchBox{
    display: flex;
    justify-content: center;
    position: absolute;
    top: 25px;
    width: 100%;
    padding: 0 10px;
     .van-icon-guide-o{
    font-size: 25px;
    color: #fff;
    margin-left: 10px;
    margin-top:5px ;
    }
  }
}
.box {
/deep/  .van-grid-item__icon{
    color: rgba(76, 189, 135);
    width: 48px;
    height: 48px;
    line-height: 49px;
    text-align: center;
    background-color: rgb(242, 251, 247);
    border-radius: 50%;
    margin-bottom: 2px;
}
/deep/ .van-grid-item__text{
  color: #333;
  font-size: 13px;

}
}
.group{
  position: relative;
  background-color: rgb(245, 246, 245);
  padding: 0 10px;
  .group-title{
    display: flex;
    justify-content: space-between;
    padding: 15px 0 15px 10px;
h3{
font-size: 15px;
}
.more{
  font-size: 14px;
}
  }
  .group-content{
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
    .item{
      display: flex;
      width: 165px;
      height: 75px;
      background-color: #fff;
      justify-content: space-around;
      align-items: center;
      margin-bottom: 10px;
      h5{
        font-size: 13px;
        margin-bottom: 5px;
      }
      p{
        font-size: 12px;
        color: #999;
      }
      img{
        width: 55px;
        height: 55px;
        border-radius: 50%;
      }
    }
  }
}
.news{
  padding: 10px 10px 50px;
     h3{
       padding: 15px 0 15px 10px;
      font-size: 15px;
     }
    .news-item{
      display: flex;
    height: 120px;
    padding: 15px 10px 15px 0;
    border-bottom: 1px solid #e5e5e5;
    background-color: #fff;
    .left {
      width: 120px;
      height: 90px;
      img{
        width: 100%;
        height: 100%;
      }
    }
    .right{
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex: 1;
      padding-left: 12px;
      padding-right: 15px;
  h6{
    font-size: 14px;
  }
  .bottom{
    position: relative;
    color: #9c9fa1;
    font-size: 12px;
    .left-span{
      float: left;
    }
        .right-span{
      float: right;
    }
  }
    }
    }
}

</style>
